<?php

class Likes extends BaseEntity{

	function __construct($id = 0){
		parent::__construct($id);
	}

	public function countByBenefitId($benefitId) {
		$sql = " select count(*) as count from Likes l INNER JOIN User u on u.id = l.userId and u.isDeleted = 0 ";
		$sql .= " where benefitId = " . $benefitId;

		return $this->repository->getValue($sql, "count");
	}

	public function isAlreadyLiked($benefitId, $userId) {
		$where = "benefitId = " . $benefitId . " and userId = " . $userId;
		if($this->search($where, "", "", "", true) > 0){
			return true;
		}else{
			return false;
		}
	}



}
?>